#include "widget.h"
#include "ui_widget.h"
#include <QThread>

Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) {
  ui->setupUi(this);
  setWindowTitle("UDP组播发送端");
}

Widget::~Widget() {
  delete ui;
}


void Widget::showMessage(const QString &info) {
  ui->messageShoxEdit->appendPlainText(info);

}

void Widget::on_btnSend_clicked() {
  QString text = ui->messageEdit->text();
  Message msg(text);
  QString ip = ui->lineEditIP->text();
  uint multicastPort = ui->lineEditPort->text().toUInt();

  QHostAddress multicastAddress(ip);
  m_udp.writeDatagram(msg.toByteArray(),  multicastAddress, multicastPort);

}

